package com.link.database.service.impl;

import com.link.database.dao.DBRegionDao;
import com.link.database.entity.DBRegion;
import com.link.database.service.DBRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DBRegionServiceImpl implements DBRegionService {
    @Autowired
    private DBRegionDao dbRegionDao;

    @Override
    public int addRegion(DBRegion dbRegion) {
        return dbRegionDao.insert(dbRegion);
    }

    @Override
    public int updateRegion(DBRegion dbRegion) {
        return dbRegionDao.update(dbRegion);
    }

    @Override
    public int deleteRegion(long id) {
        return dbRegionDao.deleteById(id);
    }

    @Override
    public DBRegion getRegionById(long id) {
        return dbRegionDao.selectById(id);
    }

    @Override
    public List<DBRegion> getAllRegions() {
        return dbRegionDao.selectAll();
    }

    @Override
    public List<DBRegion> getRegionsByZoneId(long zoneId) {
        return dbRegionDao.selectByZoneId(zoneId);
    }
}